var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]);
    })(t, e);
}, function(t, e) {
    function r() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (r.prototype = e.prototype, 
    new r());
}), a = this && this.__decorate || function(t, e, r, o) {
    var a, s = arguments.length, i = s < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, r) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, r, o); else for (var n = t.length - 1; 0 <= n; n--) (a = t[n]) && (i = (s < 3 ? a(i) : 3 < s ? a(e, r, i) : a(e, r)) || i);
    return 3 < s && i && Object.defineProperty(e, r, i), i;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = e("Global"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.levelSprite = null, t.labelSprite = null, t.stars = null, t.star = null, 
        t.starLabel = null, t.starShow = null, t.starHide = null, t.starNum = 0, t;
    }
    return i(t, e), t.prototype.onEnable = function() {}, t.prototype.start = function() {}, 
    t.prototype.refresh = function(t) {
        t = s.G.getRank(t);
        this.updateStar(t.s < t.n ? t.n : t.s), this.refreshStar(t.s), t.r < 0 && (t.r = 0), 
        11 < t.r && (t.r = 11), r.default.getInstance().loadSpriteFrame({
            url: "image/level/" + t.r,
            sprite: this.levelSprite
        }), r.default.getInstance().loadSpriteFrame({
            url: "image/label/" + t.r,
            sprite: this.labelSprite
        });
    }, t.prototype.updateStar = function(t) {
        if (5 < t) {
            for (this.starLabel.node.active = !0, this.starLabel.string = " x " + t; 1 < this.stars.childrenCount; ) this.stars.removeChild(this.stars.children[this.stars.childrenCount - 1]);
            this.stars.getComponent(cc.Layout).updateLayout(), this.starLabel.node.parent.getComponent(cc.Layout).updateLayout();
        } else if (this.starLabel.node.active = !1, this.stars.childrenCount < t) {
            for (;this.stars.childrenCount < t; ) this.stars.addChild(cc.instantiate(this.star));
            this.stars.getComponent(cc.Layout).updateLayout();
        } else if (this.stars.childrenCount > t) {
            for (;this.stars.childrenCount > t; ) this.stars.removeChild(this.stars.children[this.stars.childrenCount - 1]);
            this.stars.getComponent(cc.Layout).updateLayout();
        }
    }, t.prototype.refreshStar = function(r) {
        var o = this;
        5 < (this.starNum = r) ? this.stars.children.forEach(function(t) {
            return o.showStar(t);
        }) : this.stars.children.forEach(function(t, e) {
            return e < r ? o.showStar(t) : o.hideStar(t);
        });
    }, t.prototype.showStar = function(t) {
        t.getComponent(cc.Sprite).spriteFrame = this.starShow;
    }, t.prototype.hideStar = function(t) {
        t.getComponent(cc.Sprite).spriteFrame = this.starHide;
    }, t.prototype.showLevel = function() {
        this.levelSprite.node.active = !0;
    }, t.prototype.hideLevel = function() {
        this.levelSprite.node.active = !1;
    }, a([ d(cc.Sprite) ], t.prototype, "levelSprite", void 0), a([ d(cc.Sprite) ], t.prototype, "labelSprite", void 0), 
    a([ d(cc.Node) ], t.prototype, "stars", void 0), a([ d(cc.Node) ], t.prototype, "star", void 0), 
    a([ d(cc.Label) ], t.prototype, "starLabel", void 0), a([ d(cc.SpriteFrame) ], t.prototype, "starShow", void 0), 
    a([ d(cc.SpriteFrame) ], t.prototype, "starHide", void 0), a([ l ], t);
}(cc.Component);

n.default = u;